package www.shuang.back.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import www.shuang.common.controller.BaseController;
import www.shuang.common.util.PageInfoUtil;
import www.shuang.system.pojo.ARegion;
import www.shuang.system.service.IARegionService;

//系统相关的controller
@Controller
@RequestMapping("/back/system/")
public class SystemBackController extends BaseController
{			
			@Resource
			protected IARegionService regionService;
			//地区列表
			@RequestMapping("/regionList.htm")
			public String regionList(HttpServletRequest request){
				//接收参数
				String keyword=request.getParameter("keyword");
				String status=request.getParameter("status");
				String st=request.getParameter("st");
				String ed=request.getParameter("ed");
				String parentId=request.getParameter("parentId");
				/*if(status == null){
					status="";
				}*/
				if(st == null){
					st="";
				}
				if(ed == null){
					ed="";
				}
				if(parentId == null){
					parentId="";
				}
				Date stDate = null;
				Date edDate= null;
				if(!"".equalsIgnoreCase(st)&&!"".equalsIgnoreCase(ed)){
					stDate=this.dateFormatUtil.parseDate(st);
					edDate=this.dateFormatUtil.parseDate(ed);
				}
				PageInfoUtil pageInfoUtil =this.proccedPage(request);
				Map<String, Object> condMap=new HashMap<String,Object>();
				condMap.put("keyword", keyword);
				condMap.put("status", status);
				condMap.put("stDate", stDate);
				condMap.put("edDate", edDate);
				condMap.put("parentId", parentId);
				List<ARegion> regionList = this.regionService.findCondListARegionService(pageInfoUtil, condMap);
				//放入作用域中
				request.setAttribute("regionList", regionList);
				request.setAttribute("pageInfoUtil", pageInfoUtil);
				//
				request.setAttribute("keyword", keyword);
				request.setAttribute("status", status);
				request.setAttribute("st", st);
				request.setAttribute("ed", ed);
				request.setAttribute("parentId", parentId);
				return "/back/system/regionList";
			}
			
			//提交地区列表
			@RequestMapping("/regionListSubmit.htm")
			public String regionListSubmit(){
				
					return "";
			}
}
